package Storage_Streams.Bounded is

   -- create a memory stream with specified capacity
   type Bounded_Stream_Type (
      Capacity : Stream_Element_Count
      ) is new Storage_Stream_Type with private;

   overriding
   procedure Clear (this : in out Bounded_Stream_Type);

   overriding
   procedure Reset_For_Read (this : in out Bounded_Stream_Type);

   overriding
   procedure Reset_For_Write (this : in out Bounded_Stream_Type);

   overriding
   procedure Read (
      this : in out Bounded_Stream_Type;
      Item : out Stream_Element_Array;
      Last : out Stream_Element_Offset
      );

   overriding
   procedure Write ( 
      this : in out Bounded_Stream_Type;
      Item : Stream_Element_Array 
      );

   overriding
   function Read_Position (
      this : Bounded_Stream_Type 
      ) return Stream_Element_Offset;

   overriding
   function Write_Position (
      this : Bounded_Stream_Type 
      ) return Stream_Element_Offset;

   overriding
   procedure Set_Read_Position (
      this : in out Bounded_Stream_Type;
      Position : Stream_Element_Offset
      );

   overriding
   procedure Set_Write_Position (
      this : in out Bounded_Stream_Type;
      Position : Stream_Element_Offset
      );

private

   type Bounded_Stream_Type (
      Capacity : Stream_Element_Count
      ) is new Storage_Stream_Type with record
      F_Data : Stream_Element_Array (1 .. Capacity);
      F_Read_Index : Stream_Element_Offset := 1;
      F_Write_Index : Stream_Element_Offset := 1;
   end record;

end Storage_Streams.Bounded;
